<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title></title>
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
<meta name="description" content="">
<meta name="author" content="">
<!-- STYLESHEETS -->
<!--[if lt IE 9]>
    <script src="../../js/flot/excanvas.min.js"></script>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script><![endif]-->
<link rel="stylesheet" type="text/css" href="../../css/cloud-admin.css">
<link rel="stylesheet" type="text/css"
	href="../../css/themes/default.css" id="skin-switcher">
<link rel="stylesheet" type="text/css" href="../../css/responsive.css">
	    <!-- file-input -->
	    <link rel="stylesheet" type="text/css" href="../../js/file-input/fileinput.css" />
<link href="../../font-awesome/css/font-awesome.min.css"
	rel="stylesheet">

<!-- SELECT2 -->
<link rel="stylesheet" type="text/css"
	href="../../js/select2/select2.min.css" />
<!-- UNIFORM -->
<link rel="stylesheet" type="text/css"
	href="../../js/uniform/css/uniform.default.min.css" />
<!-- datatable -->
<link rel="stylesheet" href="../../js/datatables/datatable.css">
<link rel="stylesheet" href="../../js/datepicker/datepicker.css">
<!-- FONTS
    <link href='http://fonts.useso.com/css?family=Open+Sans:300,400,600,700' rel='stylesheet' type='text/css'>
-->
</head>
<body>
	<header class="navbar clearfix" id="header"> </header>

	<!-- PAGE -->
	<section id="page">
		<!-- SIDEBAR -->
		<div id="sidebar" class="sidebar">
			<div class="sidebar-menu nav-collapse">

				<!-- SIDEBAR MENU -->
				<ul>

				</ul>
				<!-- /SIDEBAR MENU -->
			</div>

		</div>
		<!-- /SIDEBAR -->
		<div id="main-content">
			<div class="container" id="container">
				<div class="row">
					<div id="content" class="col-lg-12">
						<!-- PAGE HEADER-->
						<div class="row">
							<div class="col-sm-12">
								<div class="page-header">
									<!-- STYLER -->

									<!-- /STYLER -->
									<!-- BREADCRUMBS -->
									<ul class="breadcrumb">
										<li><i class="fa fa-home"></i> <a href="index.html">首页</a>
										</li>
										<li><a href="#">优惠券</a></li>
										<li>补发优惠券</li>
									</ul>
									<!-- /BREADCRUMBS -->

								</div>
							</div>
						</div>
						<!-- /PAGE HEADER -->
						<!-- FORMS QUERY-->

						<div class="row">

							<div class="col-md-12">
								<div class="box border primary">
									<div class="box-title">
										<h4>
											<i class="fa fa-bars"></i>运费设置
										</h4>
									</div>
									<div class="box-body big" style="padding: 10px;">
										<form id="expressPage" class="form-horizontal" role="form">
											<div class="form-group col-sm-12 " style="display: flex">

												<label class="col-sm-1 control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px"><span
													class="required">*</span>壹果商城订单满：</label> <input type="text"
													style="width: 150px; margin-top: 7px"
													class="form-control required" name="limitPrice" maxlength=3
													onkeypress="return $.IsNum(event);"
													onblur="return $.IsNaN(this);" placeholder="输入订单金额"
													style="color:inherit"> <span
													style="width: 150px; margin-top: 7px; line-height: 34px">免运费,否则收取运费</span><input
													type="text" class="form-control required" name="exprice"
													style="width: 150px; margin-top: 7px" maxlength=2
													onkeypress="return $.IsNum(event);"
													onblur="return $.IsNaN(this);" placeholder="输入运费"
													style="color:inherit">

												<div class="col-sm-2"></div>
												<button type="button" class="btn btn-success bt-express" express_type="Yiigoo">保存</button>
											</div>
											<div class="form-group mrg-bt10"></div>
										</form>
									</div>
									<div class="box-body big" style="padding: 10px;">
										<form id="yijiadian_expressPage" class="form-horizontal" role="form">
											<div class="form-group col-sm-12 " style="display: flex">

												<label class="col-sm-1 control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px"><span
													class="required">*</span>壹家店订单满：</label> <input type="text"
													style="width: 150px; margin-top: 7px"
													class="form-control required" name="limitPrice" maxlength=3
													onkeypress="return $.IsNum(event);"
													onblur="return $.IsNaN(this);" placeholder="输入订单金额"
													style="color:inherit"> <span
													style="width: 150px; margin-top: 7px; line-height: 34px">免运费,否则收取运费</span><input
													type="text" class="form-control required" name="exprice"
													style="width: 150px; margin-top: 7px" maxlength=2
													onkeypress="return $.IsNum(event);"
													onblur="return $.IsNaN(this);" placeholder="输入运费"
													style="color:inherit">

												<div class="col-sm-2"></div>
												<button type="button" class="btn btn-success bt-express" express_type="Yijiadian">保存</button>
											</div>
											<div class="form-group mrg-bt10"></div>
										</form>
									</div>

								</div>
							</div>
						</div>

						<div class="row">
							<div class="col-md-12">
								<div class="box border primary">
									<div class="box-title">
										<h4>
											<i class="fa fa-bars"></i>女王会费
										</h4>
									</div>
									<div class="box-body big" style="padding: 10px;">
										<form id="vipPage" class="form-horizontal" role="form">
											<div class="form-group col-sm-12 " style="display: flex">

												<label class="col-sm-1 control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px">
													<span class="required">*</span>原年费：
												</label> <input type="text" style="width: 150px; margin-top: 7px"
													class="form-control required" name="sourceVipPrice"
													maxlength=3 onkeypress="return $.IsNum(event);"
													onblur="return $.IsNaN(this);" placeholder="输入金额"
													style="color:inherit"> <span class="control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px">促销价</span><input
													type="text" class="form-control required" name="vipPrice"
													style="width: 150px; margin-top: 7px" maxlength=3
													onkeypress="return $.IsNum(event);"
													onblur="return $.IsNaN(this);" placeholder="输入金额"
													style="color:inherit">

												<div class="col-sm-2"></div>
												<button type="button" class="btn btn-success bt-save">保存</button>
											</div>
											<div class="form-group mrg-bt10"></div>
										</form>
									</div>
								</div>
							</div>
						</div>
						<div class="row">

							<div class="col-md-12">
								<div class="box border primary">
									<div class="box-title">
										<h4>
											<i class="fa fa-bars"></i>新会员赠品
										</h4>
									</div>
									<div class="box-body big" style="padding: 10px;">
										<form id="skuPage" class="form-horizontal" role="form">
											<div class="form-group col-sm-12 " style="display: flex">

												<label class="col-sm-1 control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px"><span
													class="required">*</span>产品ID：</label> <input type="text"
													style="width: 150px; margin-top: 7px"
													class="form-control required" name="productId" maxlength=30
													placeholder="输入产品ID多个以英文逗号分隔" style="color:inherit">


												<div class="col-sm-2"></div>
												<button type="button" class="btn btn-success bt-save">保存</button>
											</div>
											<div class="form-group mrg-bt10"></div>
										</form>
									</div>

								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12">
								<div class="box border primary">
									<div class="box-title">
										<h4>
											<i class="fa fa-bars"></i>新会员赠券
										</h4>
									</div>
									<div class="box-body big" style="padding: 10px;">
										<form id="couponPage" class="form-horizontal" role="form">
											<div class="form-group col-sm-12 " style="display: flex">

												<label class="col-sm-1 control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px"><span
													class="required">*</span>批次ID：</label> <input type="text"
													style="width: 150px; margin-top: 7px"
													class="form-control required" name="couponBatchIds"
													maxlength=30 placeholder="输入优惠券批次ID多个以英文逗号分隔"
													style="color:inherit"> <span class="control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px">数量:</span><input
													type="text" class="form-control required" name="quantity"
													style="width: 200px; margin-top: 7px" maxlength=3
													onkeypress="return $.IsNum(event);"
													onblur="return $.IsNaN(this);" placeholder="这里指每个批次赠送数量"
													style="color:inherit">

												<div class="col-sm-2"></div>
												<button type="button" class="btn btn-success bt-save">保存</button>
											</div>
											<div class="form-group mrg-bt10"></div>
										</form>
									</div>

								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12">
								<div class="box border primary">
									<div class="box-title">
										<h4>
											<i class="fa fa-bars"></i>新客团
										</h4>
									</div>
									<div class="box-body big" style="padding: 10px;">
										<form id="newCustomGroupPage" class="form-horizontal"
											role="form">
											<div class="form-group col-sm-12 " style="display: flex">

												<label class="col-sm-1 control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px"><span
													class="required">*</span>商品ID：</label> <input type="text"
													style="width: 600px; margin-top: 7px"
													class="form-control required" name="groupProductIds"
													placeholder="输入商品ID多个以英文逗号分隔" style="color:inherit">
												<div class="col-sm-2"></div>
												<button type="button" class="btn btn-success bt-save">保存</button>
											</div>
											<div class="form-group mrg-bt10"></div>
										</form>
									</div>

								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12">
								<div class="box border primary">
									<div class="box-title">
										<h4>
											<i class="fa fa-bars"></i>粉丝群码
										</h4>
									</div>
									<div class="box-body big" style="padding: 10px; height: 150px">
										<form>
									<div class="col-md-8">									
                                      	<div hidden-image></div>
								          	<div class="fileinput fileinput-new" data-provides="fileinput" >
									          	<div class="image_preview_list" style="float:left;" id="imgs">
									          		<div class="fileinput-preview thumbnail image_preview_default" data-trigger="fileinput" style="width: 120px; height: 90px;"></div>	          		                           	
												</div>
												<div style="float:left; margin-left:5px; padding-top:23px;" class="addnewimg" id="f_span">
													<span class="btn btn-default btn-file" id="fir">
														<span class="fileinput-new" id="two" >上传图片</span>		
														<span class="fileinput-exists">Change</span>												
															<input type="file" name="uploadFile" upload-file="imageUrlProduct" fileType="QrCode">
													</span>
													<div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" style=" margin-bottom: 0px;margin-top:10px;display: none;">
													<div class="progress-bar progress-bar-success" style="width:0%;"></div>
												    </div>	
												</div>
												
											</div>
																		 								
																	
									</div>
								</form>	
									</div>

								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12">
								<div class="box border primary">
									<div class="box-title">
										<h4>
											<i class="fa fa-bars"></i>壹家店粉丝群码
										</h4>
									</div>
									<div class="box-body big" style="padding: 10px; height: 150px">
										<form>
											<div class="col-md-8">
												<div hidden-image></div>
												<div class="fileinput fileinput-new" data-provides="fileinput" >
													<div class="image_preview_list" style="float:left;" id="imgs">
														<div class="fileinput-preview thumbnail image_preview_default" data-trigger="fileinput" style="width: 120px; height: 90px;"></div>
													</div>
													<div style="float:left; margin-left:5px; padding-top:23px;" class="addnewimg" id="yijiadian_span">
													<span class="btn btn-default btn-file" id="yjd_fir">
														<span class="fileinput-new" id="two" >上传图片</span>		
														<span class="fileinput-exists">Change</span>												
															<input type="file" name="uploadFile" upload-file="yijiadianimageUrlProduct" fileType="YiJiaDian">
													</span>
														<div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" style=" margin-bottom: 0px;margin-top:10px;display: none;">
															<div class="progress-bar progress-bar-success" style="width:0%;"></div>
														</div>
													</div>

												</div>


											</div>
										</form>
									</div>

								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12">
								<div class="box border primary">
									<div class="box-title">
										<h4>
											<i class="fa fa-bars"></i>壹家店会员群码
										</h4>
									</div>
									<div class="box-body big" style="padding: 10px; height: 150px">
										<form>
											<div class="col-md-8">
												<div hidden-image></div>
												<div class="fileinput fileinput-new" data-provides="fileinput" >
													<div class="image_preview_list" style="float:left;" id="imgs">
														<div class="fileinput-preview thumbnail image_preview_default" data-trigger="fileinput" style="width: 120px; height: 90px;"></div>
													</div>
													<div style="float:left; margin-left:5px; padding-top:23px;" class="addnewimg" id="yijiadian_ua_span">
													<span class="btn btn-default btn-file" id="yjd_ua_fir">
														<span class="fileinput-new" id="two" >上传图片</span>
														<span class="fileinput-exists">Change</span>
														<input type="file" name="uploadFile" upload-file="yijiadianImgForUA" fileType="YiJiaDianUA">
													</span>
														<div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" style=" margin-bottom: 0px;margin-top:10px;display: none;">
															<div class="progress-bar progress-bar-success" style="width:0%;"></div>
														</div>
													</div>

												</div>


											</div>
										</form>
									</div>

								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12">
								<div class="box border primary">
									<div class="box-title">
										<h4>
											<i class="fa fa-bars"></i>优惠券禁用
										</h4>
									</div>
									<div class="box-body big" style="padding: 10px;">
										<form id="disableCouponGroupPage" class="form-horizontal"
											role="form">
											<div class="form-group col-sm-12 " style="display: flex">
												<label class="col-sm-1 control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px"><span
													class="required">*</span>开始时间： </label> 
													<input type="text" name="startDate" 
													style="width: 150px; margin-top: 7px" 
													class="form-control bootstrap-datepicker"> 
													<label class="col-sm-1 control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px"><span
													class="required">*</span>结束时间： </label> 
													<input type="text" name="endDate" 
													style="width: 150px; margin-top: 7px" 
													class="form-control bootstrap-datepicker"> 
												<div class="col-sm-2"></div>
												<button type="button" class="btn btn-success bt-save">保存</button>
											</div>
											<div class="form-group mrg-bt10"></div>
										</form>
									</div>
								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12">
								<div class="box border primary">
									<div class="box-title">
										<h4>
											<i class="fa fa-bars"></i>满返优惠券设置
										</h4>
									</div>
									<div class="box-body big" style="padding: 10px;">
										<form id="manFanCouponPage" class="form-horizontal" role="form">
											<div class="form-group col-sm-12 " style="display: flex">
												<label class="col-sm-1 control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px">订单实际支付满：</label> <input type="text"
													style="width: 150px; margin-top: 7px"
													class="form-control required" name="limitPrice" 
													onkeypress="return $.IsNum(event);"
													onblur="return $.IsNaN(this);" placeholder="输入订单金额"
													style="color:inherit"> <span
													style="width: 150px; margin-top: 7px; margin-left: 10px; line-height: 34px">元返优惠券</span>
													<label class="col-sm-1 control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px">优惠券批次id：</label><input type="text"
													style="width: 150px; margin-top: 7px"
													class="form-control required" name="couponBatchIds"
													maxlength=30 placeholder="输入优惠券批次ID"
													style="color:inherit"><span class="control-label"
													style=" margin-top: 7px; line-height: 34px">（多个以英文逗号分隔）</span>

												<div class="col-sm-2"></div>
												<button type="button" class="btn btn-success bt-save">保存</button>
												<button type="button" class="btn btn-danger bt-del" style="margin-left: 20px;">关闭</button>
											</div>
											<div class="form-group mrg-bt10"></div>
										</form>
									</div>
								</div>
							</div>
						</div>
							<div class="row">
							<div class="col-md-12">
								<div class="box border primary">
									<div class="box-title">
										<h4>
											<i class="fa fa-bars"></i>默认卡券设置
										</h4>
									</div>
									<div class="box-body big" style="padding: 10px;height:150px">
										<form id="saveDefaultCard" class="form-horizontal" role="form">
											<div class="form-group col-sm-12 " style="display: flex">
												<label class="col-sm-1 control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px">默认卡券id：</label> <input type="text"
													style="width: 150px; margin-top: 7px"
													class="form-control required" name="cardId" 
													onkeypress="return $.IsNum(event);"
													onblur="return $.IsNaN(this);" placeholder="请输入卡券id"
													style="color:inherit"> <span
													style="width: 150px; margin-top: 7px; margin-left: 10px; line-height: 34px"></span>
												<div class="col-sm-2"></div>
												<button type="button" class="btn btn-success bt-save" >保存</button>
												
											</div>
											<div class="form-group mrg-bt10"></div>
										</form>
										<form id="findDefaultCard" class="form-horizontal" role="form">
											<div class="form-group col-sm-12 " style="display: flex">
												<label class="col-sm-1 control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px">默认卡券：</label> 
													<div class="col-sm-2" style="margin-top: 7px; ">
															<select id="card_type_select" name="cardType" class="col-md-12 select2-offscreen" tabindex="QueenGift">
															   <option value="BasicsGift">基础礼</option>
															   <option value="QueenGift">女王礼</option>
															   <option value="BirthdayGift">生日礼</option>
															</select>												
													</div>
													<input type="text" readonly="readonly" style="width: 300px; margin-top: 6px" class="form-control required" name="cardInfo">

												<div class="col-sm-1"></div>
												<button type="button" class="btn btn-success bt-save">查询</button>
												<button type="button" class="btn btn-danger bt-del" style="margin-left: 20px;">关闭</button>
											</div>
											<div class="form-group mrg-bt10"></div>
										</form>
									</div>
								</div>
							</div>
						</div>
					<div class="row">
							<div class="col-md-12">
								<div class="box border primary">
									<div class="box-title">
										<h4>
											<i class="fa fa-bars"></i>壹家店成为代理的条件
										</h4>
									</div>
									<div class="box-body big" style="padding: 10px;">
										<form id="couponPage" class="form-horizontal" role="form">
											<div class="form-group col-sm-12 " style="display: flex">

												<label class="col-sm-1 control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px"><span
													class="required">*</span>粉丝数：</label> <input type="text"
													style="width: 150px; margin-top: 7px"
													class="form-control required" name="fans"
													onkeypress="return $.IsNum(event);"
													onblur="return $.IsNaN(this);"
													style="color:inherit"> <span class="control-label"
													style="width: 150px; margin-top: 7px; line-height: 34px">订单数:</span><input
													type="text" class="form-control required" name="ordernums"
													style="width: 200px; margin-top: 7px" maxlength=3
													onkeypress="return $.IsNum(event);"
													onblur="return $.IsNaN(this);" 
													style="color:inherit">

												<div class="col-sm-2"></div>
												<button type="button" class="btn btn-success bt-fans">保存</button>
											</div>
											<div class="form-group mrg-bt10"></div>
										</form>
									</div>

								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		</div>
		<!-- /FORMS QUERY -->
		</div>
		<!-- /TABLES -->


		<div class="footer-tools">
			<span class="go-top"> <i class="fa fa-chevron-up"></i> Top
			</span>
		</div>
		</div>
		<!-- /CONTENT-->
		</div>
		</div>

	</section>
	<!--/PAGE -->
	<!-- JAVASCRIPTS -->
	<!-- Placed at the end of the document so the pages load faster -->
	<!-- JQUERY -->
	<script src="../../js/jquery/jquery-2.0.3.min.js"></script>
	<!-- JQUERY UI-->
	<script
		src="../../js/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.min.js"></script>
	<!-- BOOTSTRAP -->
	<script src="../../bootstrap-dist/js/bootstrap.min.js"></script>
	<!-- BLOCK UI -->
	<script type="text/javascript"
		src="../../js/jQuery-BlockUI/jquery.blockUI.min.js"></script>


	<!-- AUTOSIZE -->
	<script type="text/javascript"
		src="../../js/autosize/jquery.autosize.min.js"></script>
	<!-- spinner -->
	<script src="../../js/spinner/spin.js"></script>


	<!-- INPUT MASK -->
	<script type="text/javascript"
		src="../../js/bootstrap-inputmask/bootstrap-inputmask.min.js"></script>
	<!--bootbox-->
	<script type="text/javascript" src="../../js/bootbox/bootbox.min.js"></script>

	<!-- UNIFORM -->
	<script type="text/javascript"
		src="../../js/uniform/jquery.uniform.min.js"></script>
	<script src="../../js/jquery-validate/jquery.validate.min.js"></script>
     <!-- bootstrap-fileupload -->
	    <script type="text/javascript" src="../../js/jquery-upload/js/jquery.iframe-transport.js"></script>
	    <script type="text/javascript" src="../../js/jquery-upload/js/jquery.fileupload.min.js"></script>
	    <script type="text/javascript" src="../../js/jquery-upload/js/jquery.fileupload-process.min.js"></script> 
	    <script type="text/javascript" src="../../js/jquery-upload/js/jquery.fileupload-validate.min.js"></script>
	    
	<!-- COOKIE -->
	<script type="text/javascript"
		src="../../js/jQuery-Cookie/jquery.cookie.min.js"></script>

	<script type="text/javascript" src="../../js/datepicker/datepicker.js"></script>

	<!-- CUSTOM SCRIPT -->
	<script src="../../js/script.js"></script>
	<script src="../../js/common.js"></script>
		<!-- SELECT2 -->
	<script type="text/javascript" src="../../js/select2/select2.min.js"></script>
			<script type="text/javascript" src="../../js/datatables/bootstrap-select.js"></script>
	<script>
		var CouponPage = function() {
			var cpform = $('#expressPage');
			var getExpressPage = function() {				
				   $.ajax({
	                      type: "get",
	                    	url:App.getContextPath()+ "admin/promotion/getExpress.do",
	                        data: {},
	                        success: function (result) {
	                          if(result.type == "error"){
	                              alert(result.content);
	                          }else{
	                        	  if(result.extra){
	                        		var yiigoo=JSON.parse(result.extra.Yiigoo)
	                        		if(yiigoo){
	                        			$("[name=limitPrice]").eq(0).val(yiigoo.limitPrice);
	                        			$("[name=exprice]").eq(0).val(yiigoo.price);	                        			
	                        		}
	                        		var yijiadian=JSON.parse(result.extra.Yijiadian)
	                        		if(yijiadian){
	                        			$("[name=limitPrice]").eq(1).val(yijiadian.limitPrice);
	                        			$("[name=exprice]").eq(1).val(yijiadian.price);	                        			
	                        		}
		              				 
	                        	  }
	                          }

	                      }
	                  });

			};
			var getVipPage=function(){
				var url = App.getContextPath()
				+ "admin/promotion/getVipPrice.do";		
		   $.ajax({
                  type: "get",
                	url:url,  
                data: {},
                  success: function (result) {
                      if(result.type == "error"){
                          alert(result.content);
                      }else{
                    	  if(result.extra){
                    		
                        	 $("[name=sourceVipPrice]").val(result.extra.sourceVipPrice);
              				 $("[name=vipPrice]").val(result.extra.vipPrice);
              				 
                    	  }
                      }

                  }
              });
			}
			var getCouponPage=function(){
				var url = App.getContextPath() + "admin/promotion/getCoupon.do";		
				   $.ajax({
		                  type: "get",
		                	url:url,  
		                data: {},
		                  success: function (result) {
		                      if(result.type == "error"){
		                          alert(result.content);
		                      }else{
		                    	  if(result.extra){
		                    		
		                        	 $("#couponPage [name=couponBatchIds]").val(result.extra.couponBatchIds);
		              				 $("#couponPage [name=quantity]").val(result.extra.quantity);
		              				 
		                    	  }
		                      }
		
		                  }
		            });
			}
			var setExpressPage = function() {
						var type=$(this).attr("express_type");						
						var i=type=="Yiigoo"?0:1;						
				var limitPrice = $("[name=limitPrice]").eq(i).val()
				var exprice = $("[name=exprice]").eq(i).val();
				if(limitPrice=='' || exprice ==''){
							$.alert("请输入必输项");
							return
				}
				var url = App.getContextPath()+ "admin/promotion/setExpress.do";
				
				$.confirm("确认修改运费?",function(){
			      $.ajax({
                      type: "get",
                      url:url,  
                      data: {limitPrice: limitPrice, exprice: exprice,salesPlatform:type},
                      success: function (result) {
                          if(result.type == "error"){
                              alert(result.content);
                          }else{
                        		$.alert("设置成功");
                          }

                      }
                  });
               });
			};
			var setNewCusGroup=function(){
				  $("#newCustomGroupPage").find(".bt-save").click(function(){
					var url = App.getContextPath() + "admin/groupbuying/setNewCusGroup.do";
					var pIds = $("input[name=groupProductIds]").val();
					if(pIds ==""){
						$.alert("请输入必须项");
						return false;
					}
				
					
					$.confirm("确认保存?",function(){
					      $.ajax({
		                      type: "get",
		                      url:url,  
		                      data: {productIds: pIds},
		                      success: function (result) {
		                          if(result.type == "error"){
		                              alert(result.content);
		                          }else{
		                        		$.alert("设置成功");
		                          }
	
		                      }
		                  });
		               });
				  });
			} 
			var getNewCusGroup=function(){
				var url = App.getContextPath() + "admin/groupbuying/getNewCusGroup.do";
				var pIds = $("#groupProductIds").val();
				      $.ajax({
	                      type: "get",
	                      url:url,  
	                      success: function (result) {
	                          if(result.type == "error"){
	                              alert(result.content);
	                          }else{
	                        	  $("input[name=groupProductIds]").val(result.extra);
	                          }

	                      }
	                  });
			}
			var getProductIdPage=function(){
				var url = App.getContextPath()
				+ "admin/promotion/getProduct.do";		
			   $.ajax({
	                  type: "get",
	                	url:url,  
	                data: {},
	                  success: function (result) {
	                      if(result.type == "error"){
	                          alert(result.content);
	                      }else{
	                    	  if(result.extra){
	                    		
	                        	 $("[name=productId]").val(result.extra.replace('[','').replace(']',''));
	              				
	              				 
	                    	  }
	                      }
	
	                  }
	            });
			}
			var getGiveMember=function(){
				var url = App.getContextPath()
				+ "admin/promotion/getGiveMember.do";		
			   $.ajax({
	                  type: "get",
	                	url:url,  
	                data: {},
	                  success: function (result) {
	                      if(result.type == "error"){
	                          alert(result.content);
	                      }else{
	                    	  if(result.extra){
	                    		
	                        	 $("[name=userNames]").val(result.extra);
	              				
	              				 
	                    	  }
	                      }
	
	                  }
	            });
			}
			var setGiveMember=function(userNames){
				var url = App.getContextPath() 	+ "admin/promotion/setGiveMember.do";		
			   $.ajax({
	                  type: "get",
	                	url:url,  
	                data: {userNames:userNames},
	                  success: function (result) {
	                      if(result.type == "error"){
	                          alert(result.content);
	                      }else{
	                          alert('设置成功');
	                      }
	
	                  }
	            });
			}
			var getDisableCoupon = function() {
				$.ajax({
                	type: "get",
                	url: App.getContextPath() + "admin/promotion/getDisableCoupon.do",  
                	success: function (result) {
                    	if (result.type == "error") {
                        	$.alert(result.content);
                    	} else if (result.extra) {
                    		$("#disableCouponGroupPage").find("[name='startDate']").val(result.extra.startDate);
                    		$("#disableCouponGroupPage").find("[name='endDate']").val(result.extra.endDate);
                    	}
                	}
           		});
			}
			var setDisableCoupon = function(startDate, endDate) {
				$.confirm("确认修改优惠券禁用设置?",function(){
					$.ajax({
	                	type: "get",
	                	url: App.getContextPath() + "admin/promotion/setDisableCoupon.do",  
	                	data: {startDate: startDate, endDate: endDate},
	                	success: function (result) {
	                    	if(result.type == "error"){
	                    		$.alert(result.content);
	                    	}else{
	                        	$.alert("设置成功");
	                    	}
	             		}
	            	});
   				});
			}
			 var fileUpLoad=function(){	  
					$("[upload-file=imageUrlProduct]").fileupload({
						url: App.getContextPath()+"admin/file/uploadQrcode.do",						
						dataType: 'json',
						formData:{fileType:"QrCode"},
						acceptFileTypes: /(\.|\/)(gif|jpe?g|png|JPG?g)$/i,
						iframe: true,
					    start:function(e) {
                            $("#f_span").find('.progress').fadeIn(300);
					    	return true;
				    		},
						autoUpload: true,
						done: function(e, data) {
							var result = data.result;	
							if(result.message!=""){
								$.alert(result.message);							
								return false;
							}else{
																	
					    	var $tr = $(this).closest("form");					    	
					    	$tr.find("[hidden-image]").append("<input type='hidden' name='imagePath' value='" + result.fileUrl+"' />");
					    	$tr.find(".image_preview_default").html("<img src='"+result.fileUrl+"' />");			
							}
						},						
					    progressall: function (e, data) {					    	
				            var progress = parseInt(data.loaded / data.total * 100, 10);
                            $("#f_span").find('.progress .progress-bar').css('width',progress + '%');
				        }
					}).on('fileuploaddone',function(e,data) {
                        $("#f_span").find(".progress").fadeOut(300);
					});
				
	         };
            var fileUpLoad1=function(){
                $("[upload-file=yijiadianimageUrlProduct]").fileupload({
                    url: App.getContextPath()+"admin/file/uploadQrcode.do",
                    dataType: 'json',
                    formData:{fileType:"YiJiaDian"},
                    acceptFileTypes: /(\.|\/)(gif|jpe?g|png|JPG?g)$/i,
                    iframe: true,
                    start:function(e) {
                        $("#yijiadian_span").find('.progress').fadeIn(300);
                        return true;
                    },
                    autoUpload: true,
                    done: function(e, data) {
                        var result = data.result;
                        if(result.message!=""){
                            $.alert(result.message);
                            return false;
                        }else{

                            var $tr = $(this).closest("form");
                            $tr.find("[hidden-image]").append("<input type='hidden' name='imagePath' value='" + result.fileUrl+"' />");
                            $tr.find(".image_preview_default").html("<img src='"+result.fileUrl+"' />");
                        }
                    },
                    progressall: function (e, data) {
                        var progress = parseInt(data.loaded / data.total * 100, 10);
                        $("#yijiadian_span").find('.progress .progress-bar').css('width',progress + '%');
                    }
                }).on('fileuploaddone',function(e,data) {
                    $("#yijiadian_span").find(".progress").fadeOut(300);

                });

            };
            var fileUpLoadUa=function(){
                $("[upload-file=yijiadianImgForUA]").fileupload({
                    url: App.getContextPath()+"admin/file/uploadQrcode.do",
                    dataType: 'json',
                    formData:{fileType:"YiJiaDianUA"},
                    acceptFileTypes: /(\.|\/)(gif|jpe?g|png|JPG?g)$/i,
                    iframe: true,
                    start:function(e) {
                        $("#yijiadian_ua_span").find('.progress').fadeIn(300);
                        return true;
                    },
                    autoUpload: true,
                    done: function(e, data) {
                        var result = data.result;
                        if(result.message!==""){
                            $.alert(result.message);
                            return false;
                        }else{
                            var $tr = $(this).closest("form");
                            $tr.find("[hidden-image]").append("<input type='hidden' name='imagePath' value='" + result.fileUrl+"' />");
                            $tr.find(".image_preview_default").html("<img src='"+result.fileUrl+"' />");
                        }
                    },
                    progressall: function (e, data) {
                        var progress = parseInt(data.loaded / data.total * 100, 10);
                        $("#yijiadian_ua_span").find('.progress .progress-bar').css('width',progress + '%');
                    }
                }).on('fileuploaddone',function(e,data) {
                    $("#yijiadian_ua_span").find(".progress").fadeOut(300);
                });

            };
			var setManFanCoupon = function() {
				var limitPrice = $("#manFanCouponPage [name=limitPrice]").val();
				var couponBatchIds = $("#manFanCouponPage [name=couponBatchIds]").val();
				if (limitPrice === '' || couponBatchIds === '') {
					$.alert("请输入必输项");
					return;
				}
				$.post(App.getContextPath() + "admin/promotion/setManFanCoupon.do", {limitPrice: limitPrice, couponBatchIds: couponBatchIds}, function(result){
					if (result.type === 'error') {
						$.alert(result.content);
					} else {
						$.alert('满返优惠券设置成功');
					}
				});
			}
			var delManFanCoupon = function() {
				$.confirm('确认关闭满返优惠券设置？', function(){
					$.post(App.getContextPath() + "admin/promotion/delManFanCoupon.do", function(result){
						if (result.type === 'error') {
							$.alert(result.content);
						} else {
							$("#manFanCouponPage [name=limitPrice]").val('');
							$("#manFanCouponPage [name=couponBatchIds]").val('');
							$.alert('满返优惠券关闭成功');
						}
					});
				});
			}
			var getManFanCoupon = function() {
				$.get(App.getContextPath() + "admin/promotion/getManFanCoupon.do", function(result) {
					if (result.extra) {
						$("#manFanCouponPage [name=limitPrice]").val(result.extra.limitPrice);
						$("#manFanCouponPage [name=couponBatchIds]").val(result.extra.couponBatchIds);
					}
				});
				$("#manFanCouponPage .bt-save").click(setManFanCoupon);
				$("#manFanCouponPage .bt-del").click(delManFanCoupon);
			}
			
			var setDefaultCard = function() {
				var cardId = $("#saveDefaultCard [name=cardId]").val();
				if (cardId === '') {
					$.alert("请输入必输项");
					return;
				}
				$.post(App.getContextPath() + "admin/card/setDefaultCard.do", {cardId: cardId}, function(result){
					if (result.type === 'error') {
						$.alert(result.content);
					} else {
						$.alert('设置成功');
					}
				});
			}
		
			var delDefaultCard = function() {
				var cardType =$("[name=cardType]").val();
				if (cardType === '') {
					$.alert("请输入必输项");
					return;
				}
				$.post(App.getContextPath() + "admin/card/delDefaultCard.do", {cardType:cardType}, function(result){
					if (result.type === 'error') {
						$.alert(result.content);
					} else {
						$.alert('设置成功');
					}
				});
			}
		
			var getDefaultCard = function() {
				var cardType =$("[name=cardType]").val();
				$.get(App.getContextPath() + "admin/card/getDefaultCard.do",{cardType:cardType}, function(result) {
					if (result.extra) {
						$("#findDefaultCard [name=cardInfo]").val( "cardId:"+result.extra.id +" , " + result.extra.title );
					}
				});
				$("#saveDefaultCard .bt-save").click(setDefaultCard);
				$("#saveDefaultCard .bt-del").click(delDefaultCard);
				$("#findDefaultCard .bt-save").click(getDefaultCard);
			}
			//获取壹家店的粉丝数及订单数
			var getFans=function(){
			$.get(App.getContextPath() + "admin/promotion/getUserAgentCondition.do",{salesPlatform:"Yijiadian"}, function(result) {
					if (result.extra) {
						$("[name=fans]").val(result.extra.recommendCount)
						$("[name=ordernums]").val(result.extra.orderCount)
					}
				});
			}
			return {
				init: function () {
					fileUpLoad();
					fileUpLoad1();
					fileUpLoadUa();
				     $("#card_type_select").select2({placeholder: "选择卡券类型"});
					$(".bt-express").click(setExpressPage);
				  $("#vipPage").find(".bt-save").click(function(){
					  var sourceVipPrice = $("[name=sourceVipPrice]").val();
						var vipPrice = $("[name=vipPrice]").val();
						if(sourceVipPrice=='' || vipPrice ==''){
							$.alert("请输入必输项");
							return
						}
						var url = App.getContextPath()
						+ "admin/promotion/setVipPrice.do";
						
							$.confirm("确认修改年费价格?",function(){
						      $.ajax({
			                      type: "get",
			                      url:url,  
			                      data: {sourceVipPrice: sourceVipPrice, vipPrice: vipPrice},
			                      success: function (result) {
			                          if(result.type == "error"){
			                              alert(result.content);
			                          }else{
			                        		$.alert("设置成功");
			                          }
			
			                      }
			                  });
               				});
				  });
				  
				  $("#skuPage").find(".bt-save").click(function(){
					  var productId = $("[name=productId]").val();
						
						if(productId==''){
							$.alert("请输入必输项");
							return
						}
						var url = App.getContextPath()
						+ "admin/promotion/setSku.do";
						
							$.confirm("确认修改入会赠品?",function(){
						      $.ajax({
			                      type: "get",
			                      url:url,  
			                      data: {ids:productId},
			                      success: function (result) {
			                          if(result.type == "error"){
			                              alert(result.content);
			                          }else{
			                        		$.alert("设置成功");
			                          }
			
			                      }
			                  });
             				});
				  });
				  $("#couponPage").find(".bt-save").click(function(){
					  var couponBatchIds = $("#couponPage [name=couponBatchIds]").val();
					  var quantity = $("#couponPage [name=quantity]").val();
						
						if(couponBatchIds==''){
							$.alert("请输入必输项");
							return
						}
						var url = App.getContextPath()
						+ "admin/promotion/setCoupon.do";
						
							$.confirm("确认修改优惠券?",function(){
						      $.ajax({
			                      type: "get",
			                      url:url,  
			                      data: {ids:couponBatchIds,quantity:quantity},
			                      success: function (result) {
			                          if(result.type == "error"){
			                              alert(result.content);
			                          }else{
			                        		$.alert("设置成功");
			                          }
			
			                      }
			                  });
             				});
				  });
				  $("#giveMember").find(".bt-save").click(function(){
					  var userNames = $("[name=userNames]").val();
						
						if(userNames==''){
							$.alert("请输入必输项");
							return
						}
					setGiveMember(userNames);
				  });
				  
				  
					getExpressPage();
				 	getVipPage();
				 	getProductIdPage();
				 	getCouponPage();
				 	getNewCusGroup();
				 	setNewCusGroup();
				 	getGiveMember();
				 	getDisableCoupon();
					getManFanCoupon();
					getDefaultCard();
				 	getFans();//获取粉丝数及下单数
				 	//优惠券禁用设置
		         	$.initDate($("#disableCouponGroupPage"), null, null);
					$("#disableCouponGroupPage").find(".bt-save").click(function () {
						var startDate = $("#disableCouponGroupPage").find("[name='startDate']").val();
						var endDate = $("#disableCouponGroupPage").find("[name='endDate']").val();
						if (startDate == '' || endDate == '') {
							$.alert("请输入必输项");
							return;
						}
						setDisableCoupon(startDate, endDate);
		          	});
		          	
		          	$(".bt-fans").click(function(){
		          		var fans=$("[name=fans]").val(),ordernums=$("[name=ordernums]").val();
		          		if(fans==""||ordernums==""){
		          			$.alert("请输入必输项")
		          			return ;
		          		}
		          		$.ajax({
			                      type: "get",
			                      url:App.getContextPath()+ "admin/promotion/setUserAgentCondition.do",  
			                      data: {recommendCount:fans,orderCount:ordernums,salesPlatform:"Yijiadian"},
			                      success: function (result) {
			                          if(result.type == "error"){
			                              alert(result.content);
			                          }else{
			                        		$.alert("设置成功");
			                          }
			
			                      }
			                  })
		          	})
				}
			}
		}();

		$(function() {

			$("#header").load("../head.html");
			App.init(); //Initialise plugins and elements

			CouponPage.init();

		});
	</script>
	<!-- /JAVASCRIPTS -->
</body>
</html>